﻿using System;
using System.Collections.Generic;
using System.Text;

using XISoft.AppCreator.CommonUI;

namespace XISoft.AppCreator.UI
{
    public  class SkinSubject
    {
        private static SkinSubject subject = null;
        private List<BaseForm> forms = new List<BaseForm>();

        public static SkinSubject GetInstance()
        {
            if (subject == null) subject = new SkinSubject();
            return subject;
        }

        private SkinSubject() { }

        /**/
        /// <summary>
        /// 注册观察者
        /// </summary>
        /// <param name="f"></param>
        public void Register(BaseForm f)
        {
            forms.Add(f);
        }

        /**/
        /// <summary>
        /// 注销观察者
        /// </summary>
        /// <param name="f"></param>
        public void UnRegister(BaseForm f)
        {
            forms.Remove(f);
        }

        /**/
        /// <summary>
        /// 修改每个观察者的皮肤
        /// </summary>
        /// <param name="skinName"></param>
        public void Notify(string skinName)
        {
            foreach (BaseForm f in forms)
                f.DefaultLookAndFeel.LookAndFeel.SkinName = skinName;
        }

        /**/
        /// <summary>
        /// 修改某个观察者的皮肤
        /// </summary>
        /// <param name="f"></param>
        /// <param name="defaultSkinName"></param>
        public void SetDefaultSkin(BaseForm f, string defaultSkinName)
        {
            f.DefaultLookAndFeel.LookAndFeel.SkinName = defaultSkinName;

        }
    }
}
